home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / wlzhcxp2 / mainscrn.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-12-05  |  7.5 KB  |  232 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "WLZHCXP Example"
  6.    ClientHeight    =   3585
  7.    ClientLeft      =   1320
  8.    ClientTop       =   1485
  9.    ClientWidth     =   3795
  10.    Height          =   3990
  11.    Icon            =   MAINSCRN.FRX:0000
  12.    Left            =   1260
  13.    LinkMode        =   1  'Source
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    ScaleHeight     =   3585
  17.    ScaleWidth      =   3795
  18.    Top             =   1140
  19.    Width           =   3915
  20.    Begin PictureBox Picture1 
  21.       BackColor       =   &H00FFFF00&
  22.       Height          =   1275
  23.       Left            =   120
  24.       ScaleHeight     =   1245
  25.       ScaleWidth      =   3525
  26.       TabIndex        =   8
  27.       Top             =   2220
  28.       Width           =   3555
  29.    End
  30.    Begin CommandButton Command7 
  31.       Caption         =   "E&xit"
  32.       Height          =   435
  33.       Left            =   1020
  34.       TabIndex        =   6
  35.       Top             =   1560
  36.       Width           =   1755
  37.    End
  38.    Begin CommandButton Command6 
  39.       Caption         =   "&Delete File"
  40.       Height          =   435
  41.       Left            =   1920
  42.       TabIndex        =   5
  43.       Top             =   1080
  44.       Width           =   1755
  45.    End
  46.    Begin CommandButton Command5 
  47.       Caption         =   "&Append Files"
  48.       Height          =   435
  49.       Left            =   120
  50.       TabIndex        =   4
  51.       Top             =   1080
  52.       Width           =   1755
  53.    End
  54.    Begin CommandButton Command4 
  55.       Caption         =   "C&opy File"
  56.       Height          =   435
  57.       Left            =   1920
  58.       TabIndex        =   3
  59.       Top             =   600
  60.       Width           =   1755
  61.    End
  62.    Begin CommandButton Command3 
  63.       Caption         =   "&Free Disk Space"
  64.       Height          =   435
  65.       Left            =   120
  66.       TabIndex        =   2
  67.       Top             =   600
  68.       Width           =   1755
  69.    End
  70.    Begin CommandButton Command2 
  71.       Caption         =   "&Decompress"
  72.       Height          =   435
  73.       Left            =   1920
  74.       TabIndex        =   1
  75.       Top             =   120
  76.       Width           =   1755
  77.    End
  78.    Begin CommandButton Command1 
  79.       Caption         =   "&Compress"
  80.       Height          =   435
  81.       Left            =   120
  82.       TabIndex        =   0
  83.       Top             =   120
  84.       Width           =   1755
  85.    End
  86.    Begin Label Label1 
  87.       BackColor       =   &H00C0C0C0&
  88.       Caption         =   "Status"
  89.       ForeColor       =   &H00FF0000&
  90.       Height          =   195
  91.       Left            =   120
  92.       TabIndex        =   7
  93.       Top             =   1980
  94.       Width           =   555
  95.    End
  96. ' Compression routine. Also an example of GetFileSize()
  97. Sub Command1_Click ()
  98. ' Get size of original file
  99.    insize& = GetFileSize("wlzhcxp.txt")
  100.    Picture1.Cls
  101. ' If filesize is 0, there's a problem...
  102.    If insize& = 0& Then
  103.       Picture1.Print "You must copy WLZHCXP.TXT to the"
  104.       Picture1.Print "same directory as this program"
  105.       Picture1.Print "for the program to work"
  106.       Exit Sub
  107.    End If
  108. ' Display original file size
  109.    Picture1.Print "WLZHCXP.TXT size = "; insize&; " bytes"
  110. ' Compress file into an output file
  111.    x% = Compress("wlzhcxp.txt", "wlzhcxp.cmp")
  112. ' If an error occurred, display the fact and quit
  113.    If x% <> LZH_OK Then
  114.       Picture1.Print "Error #"; x%; " occurred while"
  115.       Picture1.Print "   compressing WLZHCXP.TXT"
  116.       Exit Sub
  117.    End If
  118. ' Display compressed size and compression percentage
  119.    outsize& = GetFileSize("WLZHCXP.CMP")
  120.    Picture1.Print "WLZHCXP.CMP size = "; outsize&; " bytes"
  121.    Picture1.Print "Compression of ";
  122.    Picture1.Print Format$(100 - ((outsize& / insize&) * 100), "##.##");
  123.    Picture1.Print " percent"
  124.    Picture1.Print "   Compression Done"
  125. End Sub
  126. ' Decompression routine. You must first run Compress.
  127. Sub Command2_Click ()
  128. ' Get input file size
  129.    insize& = GetFileSize("WLZHCXP.CMP")
  130.    Picture1.Cls
  131. ' If unable to locate input file, display such.
  132.    If insize& < 10 Then
  133.       Picture1.Print "Unable to locate WLZHCXP.CMP"
  134.       Picture1.Print "You must first run the Compress"
  135.       Picture1.Print "routine to create the file!"
  136.       Exit Sub
  137.    End If
  138. ' Display byte size of input file
  139.    Picture1.Print "WLZHCXP.CMP = "; insize&; " bytes"
  140. ' Decompress file into original size
  141.    x% = Decompress("WLZHCXP.CMP", "WLZHCXP.OUT")
  142. ' If an error occurred, display it.
  143.    If x% <> LZH_OK Then
  144.       Picture1.Print "Decompress error #"; x%; " occurred"
  145.       Exit Sub
  146.    End If
  147. ' Display restored file byte size
  148.    outsize& = GetFileSize("WLZHCXP.OUT")
  149.    Picture1.Print "WLZHCXP.OUT = "; outsize&; " bytes"
  150.    Picture1.Print "   Decompression Done"
  151. End Sub
  152. '  GetFreeDiskSpace() example routine. C: drive only
  153. '     in this case.
  154. Sub Command3_Click ()
  155. ' Get space on C: drive.
  156.    freesp& = GetFreeDiskSpace("C:")
  157.    Picture1.Cls
  158. ' Display free space found on C: drive.
  159.    Picture1.Print freesp&; " bytes free on C:"
  160.    Picture1.Print "   Done"
  161. End Sub
  162. ' Copy WLZHCXP.TXT to WLZHCXP.OUT
  163. Sub Command4_Click ()
  164.    x% = CopyFile("WLZHCXP.TXT", "WLZHCXP.OUT")
  165.    Picture1.Cls
  166.    If x% <> LZH_OK Then
  167.       Picture1.Print "Copy error #"; x%; ";"; occurred; ""
  168.       Exit Sub
  169.    End If
  170.    Picture1.Print "WLZHCXP.TXT -> WLZHCXP.OUT"
  171.    Picture1.Print "   Done"
  172. End Sub
  173. ' Example of AppendFile() function
  174. Sub Command5_Click ()
  175. ' Get size of WLZHCXP.OUT
  176.    insize& = GetFileSize("wlzhcxp.out")
  177.    Picture1.Cls
  178. ' If bad file or no file, tell user and quit
  179.    If insize& < 10 Then
  180.       Picture1.Print "Unable to locate WLZHCXP.OUT"
  181.       Picture1.Print "Run Copy function first."
  182.       Exit Sub
  183.    End If
  184. ' Get WLZHCXP.TXT file size
  185.    Picture1.Print "WLZHCXP.OUT = "; insize&; " bytes"
  186.    insize& = GetFileSize("WLZHCXP.TXT")
  187.    If insize& < 3 Then
  188.       Picture1.Print "Unable to locate WLZHCXP.TXT"
  189.       Picture1.Print "Copy the file to the same directory"
  190.       Picture1.Print "as this program and run Copy."
  191.       Exit Sub
  192.    End If
  193. ' Display file size for second file
  194.    Picture1.Print "WLZHCXP.TXT = "; insize&; " bytes"
  195. ' Add WLZHCXP.TXT to WLZHCXP.OUT
  196.    x% = AppendFile("WLZHCXP.OUT", "WLZHCXP.TXT")
  197. ' If an error occurred, tell user
  198.    If x% <> LZH_OK Then
  199.       Picture1.Print "Append error #"; x%; " occurred"
  200.       Exit Sub
  201.    End If
  202. ' Display complete file size and exit
  203.    insize& = GetFileSize("WLZHCXP.OUT")
  204.    Picture1.Print "New WLZHCXP.OUT = "; insize&; " bytes"
  205.    Picture1.Print "   Append done."
  206. End Sub
  207. ' DeleteFile() example
  208. Sub Command6_Click ()
  209. ' Get size of file to delete
  210.    insize& = GetFileSize("WLZHCXP.OUT")
  211.    Picture1.Cls
  212. ' If bad file or no file, tell user and exit
  213.    If insize& < 10 Then
  214.       Picture1.Print "Unable to locate WLZHCXP.OUT"
  215.       Picture1.Print "Try running Copy first"
  216.       Exit Sub
  217.    End If
  218. ' Delete file
  219.    x% = DeleteFile("WLZHCXP.OUT")
  220. ' If error, tell user and exit
  221.    If x% <> LZH_OK Then
  222.       Picture1.Print "Delete error "; x%; " occurred."
  223.       Exit Sub
  224.    End If
  225. ' Tell user the file's gone bye-bye
  226.    Picture1.Print "WLZHCXP.OUT deleted"
  227.    Picture1.Print "   Done"
  228. End Sub
  229. Sub Command7_Click ()
  230.    End
  231. End Sub
  232.